import { defineStore } from 'pinia'
import { getHomeInfo } from '@/service/home'

export const useHomeStore = defineStore('home', {
	state: () => {
		return {
			navbars: [],
			banners: [],
			categorys: [],
		}
	},
	actions: {
		// 获取首页的数据
		async fetchHomeInfoData(type) {
			const { data } = await getHomeInfo(type)
			if (data.value.code === 200) {
				this.navbars = data.value?.data.navbars || []
				this.banners = data.value?.data.banners || []
				this.categorys = data.value?.data.categorys || []
			}
		},
	},
})
